﻿
Imports BUS
Imports DTO
Public Class TraCuuHS

    Private Sub TraCuuHS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim lhBus As New LopHocBUS
        Me.cmbLopHoc.DataSource = lhBus.LayBang()
        Me.cmbLopHoc.DisplayMember = "TenLH"
        Me.cmbLopHoc.ValueMember = "MaLH"


        Dim nhBus As New NamHocBUS
        Me.cmbNamHoc.DataSource = nhBus.LayBang()
        Me.cmbNamHoc.DisplayMember = "Nam"
        Me.cmbNamHoc.ValueMember = "MaNH"
        ' hoc ky
        For i As Integer = 1 To 2
            Me.cmbHocKy.Items.Add(i)

        Next
        ' loai kiem tra 
        Dim lktBus As New LoaiKiemTraBUS()
        Me.cmbLoaiKT.DataSource = lktBus.LayBang()
        Me.cmbLoaiKT.DisplayMember = "TenLKT"
        Me.cmbLoaiKT.ValueMember = "MaLKT"
    End Sub

    Private Sub btnTraCuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTraCuu.Click
        Try

            ' lay ho ten hs
            Dim hoTen As String
            hoTen = Me.txtHoTen.Text
            ' lay email
            Dim email As String
            email = Me.txtEmail.Text
            'lay ma lop hoc
            Dim maLH As Integer
            maLH = Me.cmbLopHoc.SelectedValue()
            'lay ma nam hoc
            Dim maNH As Integer
            maNH = Me.cmbNamHoc.SelectedValue()
            'lay ma loai kiem tra
            Dim maLKT As Integer
            maLKT = Me.cmbLoaiKT.SelectedValue()
            'lay hoc ky
            Dim hocKy As Integer
            hocKy = Me.cmbHocKy.SelectedItem()
            Dim dt As New DataTable()
            Dim hsBus As New HocSinhBUS()
            dt = hsBus.TraCuuHS(hoTen, email, maLH, maNH, hocKy, maLKT)
            Me.gridKetQua.DataSource = dt
            If (dt.Rows.Count = 0) Then
                MsgBox("Không Tìm Thấy Kết Quả Tra Cứu!")
            Else
                For i As Integer = 0 To dt.Rows.Count - 1
                    Me.gridKetQua.Rows(i).Cells("clmSTT").Value = i + 1

                Next
            End If


        Catch ex As Exception

        End Try

    End Sub
End Class
